package com.monicash.monicash.information.fragment;

import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.monicash.monicash.R;
import com.monicash.monicash.base.BaseFragment;
import com.monicash.monicash.information.CapitalInforActivity;

import java.util.Calendar;

public class LaboralInformationFragment extends BaseFragment {

    ImageView iv_payment_date_first;
    TextView et_payment_date_first;
    ImageView iv_payment_date_second;
    TextView tv_payment_date_second;
    TextView tv_submit_to;
    View view = null;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_laboral_information, container, false);
        return view;
    }

    @Override
    public void initView() {
        tv_submit_to = view.findViewById(R.id.tv_submit_to);
        iv_payment_date_first = view.findViewById(R.id.iv_payment_date_first);
        et_payment_date_first = view.findViewById(R.id.et_payment_date_first);
        iv_payment_date_second = view.findViewById(R.id.iv_payment_date_second);
        tv_payment_date_second = view.findViewById(R.id.tv_payment_date_second);
        iv_payment_date_first.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Calendar calendar = Calendar.getInstance();
                int year = calendar.get(Calendar.YEAR);
                int month = calendar.get(Calendar.MONTH);
                int day = calendar.get(Calendar.DAY_OF_MONTH);
                DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                        String dateString = year+"-"+month+"-"+dayOfMonth;
                        et_payment_date_first.setText(dateString);
                    }
                },year,month,day);
                datePickerDialog.show();
            }
        });
        iv_payment_date_second.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Calendar calendar = Calendar.getInstance();
                int year = calendar.get(Calendar.YEAR);
                int month = calendar.get(Calendar.MONTH);
                int day = calendar.get(Calendar.DAY_OF_MONTH);
                DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                        String dateString = year+"-"+month+"-"+dayOfMonth;
                        tv_payment_date_second.setText(dateString);
                    }
                },year,month,day);
                datePickerDialog.show();
            }
        });
        tv_submit_to.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CapitalInforActivity capitalInforActivity = (CapitalInforActivity) getActivity();
                if(capitalInforActivity!=null){
                    capitalInforActivity.onTabSelected(capitalInforActivity.TAG_INDEX_THREE);
                }
            }
        });

    }

    @Override
    public void initData() {

    }
}
